
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.fckeditor.net" prefix="FCK" %>
<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles" %> 
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<script type="text/javascript" src="../fckeditor/fckeditor.js"></script>
<script type="text/javascript" src="../js/datepicker.js"></script>
<link href="../css/datepicker.css" rel="stylesheet" type="text/css" />
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<script >

function createNews(){
	
	var result = true;
	var sector = document.getElementById("sector").value;
	var industry = document.getElementById("industry").value;
	var company = document.getElementById("company").value;
	var title = document.getElementById("title").value;
	//var source = document.getElementById("source").value;
	var originalPrice = document.getElementById("originalPrice").value;
	var currentPrice = document.getElementById("currentPrice").value;
	var expiredDay = document.getElementById("expiredDay").value;
	var createDate = document.getElementById("createDate").value;
	var content = document.getElementById("content").value;
	
	if(sector == 0){
		jQuery("#sector_hide").html("Please choose Sector");	
		result = false;
	}else{
		jQuery("#sector_hide").html("");
	}
	
	if(industry == 0){
		jQuery("#industry_hide").html("Please choose Industry");	
		result = false;
	}else{
		jQuery("#industry_hide").html("");
	}
	
	if(company == 0){
		jQuery("#company_hide").html("Please choose Company");	
		result = false;
	}else{
		jQuery("#company_hide").html("");
	}
	
	if(title == ""){
		jQuery("#title_hide").html("Please enter Title");	
		result = false;
	}else{
		jQuery("#title_hide").html("");
	}
	
	if(originalPrice == ""){
		jQuery("#originalPrice_hide").html("Please enter Original Price");	
		result = false;
	}else{
		jQuery("#originalPrice_hide").html("");
	}
	
	if(currentPrice == ""){
		jQuery("#currentPrice_hide").html("Please enter Current Price");	
		result = false;
	}else{
		jQuery("#currentPrice_hide").html("");
	}
	
	if(expiredDay == ""){
		jQuery("#expiredDay_hide").html("Please enter Expired Day");	
		result = false;
	}else{
		jQuery("#expiredDay_hide").html("");
	}
	
	if(createDate == ""){
		jQuery("#createDate_hide").html("Please enter create Day");	
		result = false;
	}else{
		jQuery("#createDate_hide").html("");
	}
	
	if(content == "" || content.length == 0){
		jQuery("#content_hide").html("Please enter Content of New");	
		result = false;
	}else{
		jQuery("#content_hide").html("");
	}
}
function showContent(){
	var content = FCKeditorAPI.GetInstance("myeditor").GetHTML(false);
	alert(content);
	document.getElementById("content").innerHTML = content;
}
function clearContent(){
	FCKeditorAPI.GetInstance("myeditor").setHTML("");
}
</script>
<div align="left" style="padding:10px; border:1px solid #dfdfdf;">
	<div style="font-size:20px;" align="center">create news</div>
	<br/>
	<table class="table_default" cellpadding="5" style="margin-left:30px;">
		<tr>
			<td width="30%"  align="right"> Sector: </td>
			<td width="3%"><span class="note">*</span></td>
			<td>
				
				<select id="sector" name="sector" class="input_default" onchange="javascript:getIndustryList();">
				<option value="0">Chọn Nhóm Ngành</option>
				<c:forEach items="${listSector}" var="sectorItem" varStatus="status">
					<option value="${sectorItem.sectorId}">${sectorItem.sectorName }</option>
				</c:forEach>		
				</select>
			</td>
		</tr>
		<tr><td></td><td></td><td><div id="sector_hide" class="note"></div></td></tr>
		<tr>
			<td  align="right"> Industry: </td>
			<td width="3%"><span class="note">*</span></td>
			<td>
				<select id="industry" name="industry" class="input_default" onchange="javascript:getCompanyList();">
				<option value="0">Chọn Ngành</option>						
				</select>
			</td>
		</tr>
		<tr><td></td><td></td><td><div id="industry_hide" class="note"></div></td></tr>
		<tr>
			<td align="right"> Company: </td>
			<td width="3%"><span class="note">*</span></td>
			<td>
				<select id="company" name="company" class="input_default" >
				<option value="0">Chọn Công ty</option>						
				</select>
			</td>
		</tr>
		<tr><td></td><td></td><td><div id="company_hide" class="note"></div></td></tr>
		<tr>
			<td  align="right"> Title: </td>
			<td width="3%"><span class="note">*</span></td>
			<td>
				<input type="text" id="title" name="title" class="input_default" style="width:500px;"/>
			</td>
		</tr>
		<tr><td></td><td></td><td><div id="title_hide" class="note"></div></td></tr>
		<tr>
			<td  align="right"> Image: </td>
			<td width="3%"><span class="note"></span></td>
			<td>
				<input type="text" id="image" name="image" class="input_default" style="width:440px;"/>&nbsp;<input type="button" value="brow" class="bt_detail"/>
			</td>
		</tr>
		<tr>
			<td  align="right"> File path: </td>
			<td width="3%"><span class="note"></span></td>
			<td>
				<input type="text" id="filePath" name="filePath" class="input_default" style="width:440px;"/>&nbsp;<input type="button" value="brow" class="bt_detail"/>
			</td>
		</tr>
		<tr>
			<td  align="right"> Category: </td>
			<td width="3%"><span class="note"></span></td>
			<td>
				<select id="category" name="category" class="input_default" >
				<option value="1">New type 1</option>		
				<option value="2">New type 2</option>
				<option value="3">New type 3</option>				
				</select>
			</td>
		</tr>
		<tr>
			<td  align="right"> Source: </td>
			<td width="3%"><span class="note"></span></td>
			<td>
				<input type="text" id="source" name="source" class="input_default"/>
			</td>
		</tr>
		<tr>
			<td  align="right"> Original Price : </td>
			<td width="3%"><span class="note">*</span></td>
			<td>
				<input type="text" id="originalPrice" name="originalPrice" class="input_default"/>
			</td>
		</tr>
		<tr><td></td><td></td><td><div id="originalPrice_hide" class="note"></div></td></tr>
		<tr>
			<td  align="right"> Current Price : </td>
			<td width="3%"><span class="note">*</span></td>
			<td>
				<input type="text" id="currentPrice" name="currentPrice" class="input_default"/>
			</td>
		</tr>
		<tr><td></td><td></td><td><div id="currentPrice_hide" class="note"></div></td></tr>
		<tr>
			<td  align="right"> Expired Day : </td>
			<td width="3%"><span class="note">*</span></td>
			<td>
				<input type="text" id="expiredDay" name="expiredDay" class="input_default"/>
			</td>
		</tr>
		<tr><td></td><td></td><td><div id="expiredDay_hide" class="note"></div></td></tr>
		<tr>
			<td  align="right"> Create Date: </td>
			<td width="3%"><span class="note">*</span></td>
			<td>
				<input type="text" class="w16em dateformat-d-sl-m-sl-Y" id="createDate" name="createDate"/><span> &nbsp; Ex: 31/12/2011</span>
			</td>
		</tr>
		<tr><td></td><td></td><td><div id="createDate_hide" class="note"></div></td></tr>
		<tr>
			<td  align="right"> Create By: </td>
			<td width="3%"><span class="note"></span></td>
			<td>
				<input type="text" id="createBy" name="createBy" class="input_default"/>
			</td>
		</tr>
		
	</table>
	<table width="100%">
		<tr><td>Content: <span class="note">*</span></td></tr>
		<tr><td><div id="content_hide" class="note"></div></td></tr>
		<tr>
		<tr>
			
			<td><div style="padding:10px;">
				<textarea id="content" name="content" cols="80" rows="24" wrap="virtual"/>
				</textarea>
				</div>
			</td>
		</tr>
	</table>
	<br>
	
	<script type="text/javascript">
	    var name = 'content';
	    //var base_url = window.location.href;
	   // base_url = base_url.substring(0,base_url.indexOf('/tag.'));
	    var editor = new FCKeditor(name,'100%','400','Default') ;
	    //editor.BasePath= 'fckeditor/';
	    //editor.Width = '900px';
	    //editor.Height = '400px'; 
		
	    editor.ReplaceTextarea() ;
	</script>
<div align="center">
	<input type="button" value="Submit" class="bt_detail" onclick="javascript:createNews();" />
	<input type="button" value="Clear" class="bt_detail" onclick="javascript:clearContent();" />
</div>
<div style="background:#f1f1f1; padding:10px;">
	<h4>The content of editor:</h4>
	<div id="content" >
	</div>
</div>
</div>
